<?php

namespace App\Http\Requests;

use App\Exceptions\ApiException;
use Illuminate\Foundation\Http\FormRequest;

class ZhuangxiuRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'area'=>'required',
            'kaijian'=>'required',
            'jinshen'=>'required',
            'cenggao'=>'required',
            'fengge'=>'required',
            'yaoqiu'=>'required',
        ];
    }
    public function messages()
    {
        return [
            'area.required'=>'请填写面积',
            'kaijian.required'=>'请填写开间',
            'jinshen.required'=>'请填写进深',
            'cenggao.required'=>'请填写层高',
            'fengge.required'=>'请填写装修风格',
        ];
    }
    protected function failedValidation(\Illuminate\Contracts\Validation\Validator $validator)
    {
        throw new ApiException($validator->errors()->first());
    }
}
